package com.ruoyi.statistics.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistics.domain.LabStatisticsBase;
import com.ruoyi.statistics.service.ILabStatisticsBaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 高基Controller
 * 
 * @author jun.wang
 * @date 2022-05-12
 */
@RestController
@RequestMapping("/statistics/base")
public class LabStatisticsBaseController extends BaseController
{
    @Autowired
    private ILabStatisticsBaseService labStatisticsBaseService;

    /**
     * 查询高基列表
     */
//    @PreAuthorize("@ss.hasPermi('statistics:base:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabStatisticsBase labStatisticsBase)
    {
        startPage();
        List<LabStatisticsBase> list = labStatisticsBaseService.selectLabStatisticsBaseList(labStatisticsBase);
        return getDataTable(list);
    }

    /**
     * 导出高基列表
     */
//    @PreAuthorize("@ss.hasPermi('statistics:base:export')")
    @Log(title = "高基", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabStatisticsBase labStatisticsBase)
    {
        List<LabStatisticsBase> list = labStatisticsBaseService.selectLabStatisticsBaseList(labStatisticsBase);
        ExcelUtil<LabStatisticsBase> util = new ExcelUtil<LabStatisticsBase>(LabStatisticsBase.class);
        return util.exportExcel(list, "base");
    }

    /**
     * 获取高基详细信息
     */
//    @PreAuthorize("@ss.hasPermi('statistics:base:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(labStatisticsBaseService.selectLabStatisticsBaseById(id));
    }

    /**
     * 新增高基
     */
//    @PreAuthorize("@ss.hasPermi('statistics:base:add')")
    @Log(title = "高基", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabStatisticsBase labStatisticsBase)
    {
        return toAjax(labStatisticsBaseService.insertLabStatisticsBase(labStatisticsBase));
    }

    /**
     * 修改高基
     */
//    @PreAuthorize("@ss.hasPermi('statistics:base:edit')")
    @Log(title = "高基", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabStatisticsBase labStatisticsBase)
    {
        return toAjax(labStatisticsBaseService.updateLabStatisticsBase(labStatisticsBase));
    }

    /**
     * 删除高基
     */
//    @PreAuthorize("@ss.hasPermi('statistics:base:remove')")
    @Log(title = "高基", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(labStatisticsBaseService.deleteLabStatisticsBaseByIds(ids));
    }
}
